class ApiException implements Exception {
  final String message;
  final int? statusCode;
  final String? code;

  const ApiException(
    this.message, {
    this.statusCode,
    this.code,
  });

  @override
  String toString() {
    return 'ApiException: $message${statusCode != null ? ' (Code: $statusCode)' : ''}';
  }
}

class NetworkException extends ApiException {
  const NetworkException(super.message) : super(statusCode: -1, code: 'NETWORK_ERROR');
}

class ServerException extends ApiException {
  const ServerException(super.message, {super.statusCode}) : super(code: 'SERVER_ERROR');
}

class ValidationException extends ApiException {
  const ValidationException(super.message) : super(statusCode: 400, code: 'VALIDATION_ERROR');
}

class NotfoundException extends ApiException {
  const NotfoundException(super.message) : super(statusCode: 404, code: 'NOT_FOUND');
}

class UnauthorizedException extends ApiException {
  const UnauthorizedException(super.message) : super(statusCode: 401, code: 'UNAUTHORIZED');
}